package com.example.kotlin_test

class Person {
    var lastName:String="zhang"
    get()=field.toUpperCase() // 将变量赋值后转换为大写
    set

    var no:Int = 100
    get() = field
    set(value){
        if(value<10){
            field = value
        }else{
            field=-1
        }
    }

    var heiht:Float=145.4f
    private set
}


class Runoob constructor(name:String){
    var url: String = "http://www.runoob.com"
    var country: String = "CN"
    var siteName = name

    init{
        println("初始化网站名: ${name}")
    }

    fun printTest() {
        println("我是类的函数")
    }

    // 次构造函数
    constructor(name:String,alexa:Int):this(name){
        println("Alexa 排名 $alexa")
    }
}


fun main(args:Array<String>){
    var person:Person = Person()
    person.lastName = "wang"

    println("lastNam: ${person.lastName}")

    person.no = 9
    println("no: ${person.no}")

    person.no=29
    println("no: ${person.no}")
    println("height: ${person.heiht}")

    val runoob =  Runoob("菜鸟教程",1000)
    println(runoob.siteName)
    println(runoob.url)
    println(runoob.country)
    runoob.printTest()
}